using Unity.VisualScripting;
using GameFramework.DataNode;

namespace LS.UGFUnits
{
    [UnitSurtitle("Download Property")]
    [UnitShortTitle("Get")]
    public sealed class GetDownloadProperty : DownloadUnit
    {
        [DoNotSerialize]
        public ValueOutput Paused { get; private set; }

        [DoNotSerialize]
        public ValueOutput TotalAgentCount { get; private set; }
        
        [DoNotSerialize]
        public ValueOutput FreeAgentCount { get; private set; }
        
        [DoNotSerialize]
        public ValueOutput WorkingAgentCount { get; private set; }
        
        [DoNotSerialize]
        public ValueOutput WaitingTaskCount { get; private set; }
        
        [DoNotSerialize]
        public ValueOutput Timeout { get; private set; }
                
        [DoNotSerialize]
        public ValueOutput FlushSize { get; private set; }
        
        [DoNotSerialize]
        public ValueOutput CurrentSpeed { get; private set; }
        
        protected override void Definition()
        {
            base.Definition();
            Paused = ValueOutput<bool>(nameof(Paused));
            TotalAgentCount = ValueOutput<int>(nameof(TotalAgentCount));
            FreeAgentCount = ValueOutput<int>(nameof(FreeAgentCount));
            WorkingAgentCount = ValueOutput<int>(nameof(WorkingAgentCount));
            WaitingTaskCount = ValueOutput<int>(nameof(WaitingTaskCount));
            Timeout = ValueOutput<float>(nameof(Timeout));
            FlushSize = ValueOutput<int>(nameof(FlushSize));
            CurrentSpeed = ValueOutput<float>(nameof(CurrentSpeed));
        }

        protected override ControlOutput In(Flow flow)
        {
            flow.SetValue(Paused, Target?.Paused ?? false);
            flow.SetValue(TotalAgentCount, Target?.TotalAgentCount ?? 0);
            flow.SetValue(FreeAgentCount, Target?.FreeAgentCount ?? 0);
            flow.SetValue(WorkingAgentCount, Target?.WorkingAgentCount ?? 0);
            flow.SetValue(WaitingTaskCount, Target?.WaitingTaskCount ?? 0);
            flow.SetValue(Timeout, Target?.Timeout ?? 0);
            flow.SetValue(FlushSize, Target?.FlushSize ?? 0);
            flow.SetValue(CurrentSpeed, Target?.CurrentSpeed ?? 0);
            return base.In(flow);
        }
    }
}